<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	layout(false);
        $this->display();
    }
    public function login(){
        // var_dump($_POST);
        // $name=$_POST['name'];
        // $password=$_POST['password'];

        $info['name']=$_POST['name'];
        $info['password']=$_POST['password'];
        $user = M("user"); // 实例化User对象
		// 查找status值为1name值为think的用户数据 
		// $data = $user->where('name="'.$name.'" AND password="'.$password.'"')->find();
		$data = $user->where($info)->find();
		// var_dump($data['name']);
		if(count($data)>0){
			cookie('username',$data['name'],3600);
			cookie('userid',$data['id'],3600);
			$this->success('登录成功', U('Index/index'));

		}else{
			$this->error('登录失败');
		}
    }
}